//收集手机号和验证码数据
document.querySelector('.btn').addEventListener('click',()=>{
    const form = document.querySelector('.login')
    const data = serialize(form,{hash:true,empty:true})
    console.log(data);
    //基于axios调用验证登录接口
    if (data.mobile.length !== 11) {
        myAlert(false,'手机长度要11位')
        return
    }
    if (data.code.length !== 6) {
        myAlert(false,'密码长度要6位')
        return
    }
    axios({
        method:'post',
        url: '/v1_0/authorizations',
        data
    }).then(result =>{
        myAlert(true,'登录成功')
        console.log(result);

        //保存token令牌字符串到本地，并跳转到内容列表页面
        localStorage.setItem('token',result.data.token)
        setTimeout(()=>{
            location.href = '../content/content.html'
        },100)
        
    }).catch(error =>{
        myAlert(false,error.response.data.message)
        console.dir(error.response.data.message);
    })
})